<template>
	<view>
		<view class="app">
			<view class="sign">
				<image @click="open" src="../../../static/img/data.png" mode=""></image>
				<view>
					<uni-calendar ref="calendar" :insert="false" @confirm="confirm" :clearDate="false"></uni-calendar>
					<view @click="open" class="">
						<!-- {{createTime}} -->
						<text class="calendar">{{createTime}}</text>
						<uni-icons type="arrowright"></uni-icons>
					</view>
				</view>
			</view>
			<!-- 列表 -->
			<view class="" v-if="rcordList.length > 0">
				<uni-card   v-for="(item,index) in rcordList" :key="index">
					<view class="record">
						<view class="time">
							{{item.createTime}} 签到
						</view>
						<view class="address">
							<image src="../../../static/img/address.png" mode=""></image>
							{{item.addressDetails}}
						</view>
					</view>
				</uni-card>
			</view>
			
			<view v-else>
				<null-page></null-page>
			</view>
		</view>
	</view>
</template>

<script>
	import uniCalendar from '@/components/uni-calendar/uni-calendar.vue'
	import sign from "@/serve/api/sign.js"
	import {formatTime} from "@/static/js/dateUtil.js"
	import nullPage from '@/common/null.vue'
	export default {
		components: {
			uniCalendar,nullPage
		},
		data() {
			return {
				rcordList: [],
				pageNum: 1,
				getListFlag: true,
				createTime: "",
			}
		},
		onLoad() {
			this.getrcordList();
		},
		methods: {
			// 日历
			open() {
				this.$refs.calendar.open();
			},
			
			// 查询日期
			confirm(e) {
				this.createTime = e.fulldate
				this.getListFlag = true;
				this.pageNum = 1;
				this.rcordList = []
				this.getrcordList();
			},

			// 记录列表的接口
			async getrcordList() {
				if (this.createTime == '') {
					this.createTime = formatTime(new Date())
				}
				const res = await sign.userMineSignList({
					pageNum: this.pageNum,
					pageSize: 10,
					createTime: this.createTime
				});
				if(res){
					if (res.data.data.list.length < 10) {
						this.getListFlag = false;
					}
					this.rcordList.push(...res.data.data.list)
				}
				
			},
		},
		onReachBottom(e) {
			if (this.getListFlag) {
				this.pageNum = this.pageNum + 1;
				this.rcordList();
			}
		}

	}
</script>

<style scoped>
	* {
		margin: 0;
		padding: 0;
	}

	page {
		width: 750rpx;
		background: #EFF2F5;
		overflow: hidden;
	}

	view {
		font-size: 28rpx;
		line-height: 1.8;

	}

	/* 日历 */
	.calendar {
		height: 23rpx;
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: 400;
		color: #34363D;
	}

	.uni-card {
		width: 670rpx;
		/* height: 96rpx; */
		background: #FFFFFF;
		box-shadow: 0rpx 10rpx 10rpx 0rpx rgba(52, 54, 61, 0.05);
		border-radius: 16rpx;
		border: none;
		margin: 0 auto;
		margin-top: 10px;

	}

	.sign {
		display: flex;
		flex-direction: row;
		justify-content: flex-start;
		align-items: center;
	}

	.sign image {
		width: 30rpx;
		height: 30rpx;
		vertical-align: middle;
		padding: 0 20rpx 0 40rpx;
		/* margin: 0 20rpx; */
	}

	.record {
		margin-left: 10rpx;
	}

	.time {

		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #34363D;

	}

	.address {

		font-size: 24rpx;
		font-family: PingFang SC;
		font-weight: 400;
		color: #989BA6;
		word-spacing: 5px;
	}

	.address image {
		width: 20rpx;
		height: 24rpx;
		color: #989BA6;
		margin: 0 10rpx;
		vertical-align: middle;
	}
</style>
